package com.j.sdks.util;

import java.io.IOException;
import java.util.Properties;

public class AppConfigurator {
	private static AppConfigurator property;
	private Properties pro;

	private AppConfigurator() {
		pro = new Properties();
		java.io.InputStream inStream = getClass().getClassLoader()
				.getResourceAsStream("appConfigurator.properties");
		try {
			if (inStream == null)
				throw new NullPointerException(
						"classes \u76EE\u5F55\u4E0B\u627E\u4E0D\u5230 appConfigurator.properties \u5C5E\u6027\u6587\u4EF6");
			pro.load(inStream);
		} catch (IOException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static AppConfigurator getInstance() {
		if (property == null)
			property = new AppConfigurator();
		return property;
	}

	public static final String getProperty(String propertyKey) {
		return getInstance().pro.getProperty(propertyKey);
	}

	public static final int getProperty(String propertyKey, int defaultInt) {
		int resultInt = defaultInt;
		try {
			resultInt = Integer.valueOf(
					(String) getInstance().pro.get(propertyKey)).intValue();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return resultInt;
	}

}
